#{extends 'main.html' /}
#{set title:'Teacher Salary' /}

<h2>Salary for ${date}</h2>
<form id ="form" action="@{Attendance.getSalary()}" method="POST">
    Select a teacher <select size="1" name="id" onchange="this.form.submit()"> 
                <option value="">--</option>
            #{list items:models.Teacher.findAll(), as:'su'}
                #{if su.id == id}
                <option selected="selected" value="${su.id}">${su.name}</option>
                #{/if}
                #{else}
                 <option value="${su.id}">${su.name}</option>
                #{/else}
            #{/list}
           </select> 

</form>



<br>

#{if id!= null}

<h3>Set Value per Class </h3>

<form id ="form" action="@{Attendance.setPercentage()}" method="POST">
    <input type="hidden" name="id" value="${id}">
    <table border="1">
    <tr><td>Value</td> 
    <td><input type="text" value="${per}" name="amount" required="required">
    <input type="submit" value="+" title="submit value"> </td>
	</tr>
	</table>
</form>
<br>



<div id="andrew">
<h3> Classes for ${date}</h3>

<table border="1">
    <tr>
    <th> Reg ID </th>
    <th> Class ID </th>
    <th> Student </th>
    <th> Course </th>
    <th> DateTime </th>
    <th> Student Attendance</th>
    <th> Teacher Attendance</th>
    
    </tr>
    	#{list items:cs, as:'cl'}
    	<tr>
    	<td>${cl.registration.id}</td>
    	<td>${cl.id}</td>
    	<td>${cl.registration.student.getName()}</td>
    	<td>${cl.registration.course.name}</td>
    	<td>${cl.datetime}</td>
    	<td>${cl.decodeA(cl.student_attendance)}</td>
    	<td>${cl.decodeA(cl.teacher_attendance)}</td>
    	</tr>
    	#{/list}
    </table>

</div>
<br>

<button onclick="cl()" >Hide Classes</button>

<br>
<br>

<h3>Set Salary </h3>

<form id ="form" action="@{Attendance.setSalary()}" method="POST">
    <input type="hidden" name="id" value="${id}">
    <table border="1">
    <tr><td>Number of Taught Classes</td><td>${at}</td>
    <tr><td>Salary Calculated</td><td>${amount}</td>
    <tr><td>Salary</td> 
    <td><input type="text" value="${salary}" name="amount" required="required">
    <input type="submit" value="+" title="submit value"> </td>
	</tr>
	</table>
</form>

#{/if}
<br>
<br>
<br>
<br>

<script type="text/javascript">

	var sD = false;
			
	function cl(){
    	
		if(sD)
		{
			$("#andrew").show(500);
			sD = false;
			$("button").html("Hide Classes");
			
		}
		else {
			$("#andrew").hide(500);
			sD = true;
			$("button").html("View Attended Classes");
			
			}
    	}
    
    
    
</script>

